/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Ruben
 */
public class Carga {

    //public Robot cRobot = new Robot();
    //public CopiarRobot copiaRobot=new CopiarRobot();
    

    public Carga() {
    }

    public void cargaAlgoritmo() {
        FileInputStream fileInput = null;
        try {
            ObjectInputStream in = null;
            String ficheroOriginal = "C:/Users/Ruben/Documents/JSF/IlusCode/src/iluscode/program.dat";
            fileInput = new FileInputStream(ficheroOriginal);
            in = new ObjectInputStream(fileInput);
            Algoritmo alg = (Algoritmo) in.readObject();

            //alg.Imprimir();
            in.close();

            //cRobot.setAlgoritmo(alg);
            //copiaRobot.setAlgoritmo(alg);
            //System.out.println("Termino de cargar Algoritmo");
            
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Carga.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Carga.class.getName()).log(Level.SEVERE, null, ex);

        } finally {
            try {
                fileInput.close();
            } catch (IOException ex) {
                Logger.getLogger(Carga.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

    }

    public void cargaAlgoritmo(InputStream is) {
        try {

            ObjectInputStream in = new ObjectInputStream(is);
            Algoritmo alg = (Algoritmo) in.readObject();
            System.out.println("Error read");
            in.close();
            //cRobot.setAlgoritmo(alg);
            System.out.println("Termino de cargar Algoritmo");

        } catch (Exception e) {
            //e.printStackTrace();
            System.out.println("No carga algoritmo");
        }
    }
}
